import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from 'axios';
import './assets/css/public.scss';

import {
	Button,
	Form,
	Field
} from 'vant'
import {
	Icon
} from 'vant'
import {
	Grid,
	GridItem
} from 'vant'
import {
	Cell,
	CellGroup
} from 'vant'
import {
	NavBar
} from 'vant'
import {
	RadioGroup,
	Radio
} from 'vant'
import {
	Popup
} from 'vant'
import {
	Popover
} from 'vant'
import {
	Dialog
} from 'vant'
import {
	List
} from 'vant'
import {
	Tab,
	Tabs
} from 'vant';
import {
	Picker
} from 'vant';
import {
	Calendar
} from 'vant';
import {
	Cascader
} from 'vant';
import {
	DatetimePicker
} from 'vant';
import {
	Divider
} from 'vant';
import {
	AddressEdit
} from 'vant';
import {
	Uploader
} from 'vant';
import {
	PullRefresh
} from 'vant';
import {
	Step,
	Steps
} from 'vant';

import { Image as VanImage } from 'vant';
import { Loading } from 'vant';
import { Toast } from 'vant';
import { Badge } from 'vant';
import { Tag } from 'vant';
import { Col, Row } from 'vant';
import { Collapse, CollapseItem } from 'vant';
import request from "./utils/request";
import { Tabbar, TabbarItem } from 'vant';

Vue.use(Tabbar);
Vue.use(TabbarItem);
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(Button)
Vue.use(Form)
Vue.use(Field)
Vue.use(Grid)
Vue.use(GridItem)
Vue.use(Cell)
Vue.use(CellGroup)
Vue.use(NavBar)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(Icon)
Vue.use(Popup)
Vue.use(Dialog)
Vue.use(Popover)
Vue.use(List)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Picker)
Vue.use(Calendar)
Vue.use(Cascader)
Vue.use(DatetimePicker)
Vue.use(Divider)
Vue.use(AddressEdit)
Vue.use(Uploader)
Vue.use(PullRefresh)
Vue.use(Step)
Vue.use(Steps)
Vue.use(VanImage)
Vue.use(Toast)
Vue.use(Badge)
Vue.use(Tag)
Vue.use(Loading)
Vue.use(Col);
Vue.use(Row);

Vue.config.productionTip = false;
Vue.prototype.axios = axios;
Vue.prototype.request = request;
axios.defaults.baseURL = process.env.VUE_APP_BASE_URL;

router.beforeEach((to, from, next) => {
	if(to.meta.title) {
		document.title = to.meta.title;
	}
	next()
})

Date.prototype.format = function (format) {
  var o = {
    "M+": this.getMonth() + 1,
    "d+": this.getDate(),
    "h+": this.getHours(),
    "m+": this.getMinutes(),
    "s+": this.getSeconds(),
    "q+": Math.floor((this.getMonth() + 3) / 3),
    "S": this.getMilliseconds()
  };
  if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    }
  }
  return format;
};

Array.prototype.remove = function(val) {
  var index = this.indexOf(val);
  if (index > -1) {
    this.splice(index, 1);
  }
};

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
